<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class history_model extends CI_Model {

	public function get_history($per_page ,$uri ,$mem_id)
	{
		$this->db->limit($per_page ,$uri);
		$this->db->where('thumb_choose',1);
		$this->db->where('history.mem_id' ,$mem_id);
		$this->db->order_by('his_id' , 'desc');
		$this->db->join('vdo','vdo.vdo_id = history.vdo_id','left');
		$this->db->join('vdo_thumb','vdo_thumb.vdo_id = history.vdo_id','left');
		$query = $this->db->get('history');
		return $query->result_array();
	}

	public function count_get_history($mem_id)
	{
		$this->db->where('thumb_choose',1);
		$this->db->where('history.mem_id' ,$mem_id);
		$this->db->order_by('his_id' , 'desc');
		$this->db->join('vdo','vdo.vdo_id = history.vdo_id','left');
		$this->db->join('vdo_thumb','vdo_thumb.vdo_id = history.vdo_id','left');
		$query = $this->db->get('history');
		return count($query->result_array());
	}

	public function delete_history($id)
	{
		$this->db->where('his_id' ,$id);
		$this->db->delete('history');
	}

	
	

}